package uos.gcds.menu;

import java.util.ArrayList;
import java.util.List;

import uos.gcds.Item;
import uos.gcds.decoration.Decoration;
import uos.gcds.food.Food;
import uos.gcds.style.Style;

public class Menu extends Item {
	
	private List<MenuLineItem> foodItems;
	private Style style;
	private Decoration decoration;
	
	public Menu(String name, String detail, int price){
		this.setName(name);
		this.setDetail(detail);
	}
	
	public Menu() {
	}

	public int getPrice(){
		int price = 0;
		
		List<MenuLineItem> mliList = this.getAllMenuLineItems();
		
		if( mliList != null ){
			MenuLineItem mli;
			for( int i=0; i<mliList.size(); i++){
				mli = mliList.get(i);
				price += mli.getSubTotal();
			}
		}
		
		if( this.getStyle() != null ){
			price += this.getStyle().getPrice();
		}
		
		if( this.getDecoration() != null ){
			price += this.getDecoration().getPrice();
		}
		
		return price;
	}
	
	public List<MenuLineItem> getAllMenuLineItems(){
		if (this.foodItems == null)
			this.foodItems = new ArrayList();
		return this.foodItems;
	}
	
	public void setAllMenuLineItems(List<MenuLineItem> item){
		this.foodItems = item;
	}
	
	public void setStyle(Style style){
		this.style = style;
	}
	
	public Style getStyle(){
		return this.style;
	}
	
	public void setDecoration(Decoration decoration){
		this.decoration = decoration;		
	}

	public Decoration getDecoration(){
		return this.decoration;
	}

	public void addMenuLineItem(Food fd, int qty){
		MenuLineItem menuLineItem = new MenuLineItem(fd, qty);
		this.getAllMenuLineItems().add(menuLineItem);
	}


	public void updateItem(Item desc) {
		Menu item = (Menu)desc;
		this.setName(item.getName());
		this.setDetail(item.getDetail());
		this.setAllMenuLineItems(item.getAllMenuLineItems());
	}
	
	
}
